<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>PowerVR SDK</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
<table width="100%">
  <tr>
    <td width="33%">
      <p align="left">&nbsp;<a href="http://www.imgtec.com"><img border="0" src="IMGLogo.jpg" width="200" height="30"></a></p>
    </td>
    <td width="33%">
      <p align="center"><font color="#808080" face="Arial" size="2">PowerVR Software Development Kit</a></font></p>
    </td>
    <td width="34%">
      <p align="right"><a href="http://www.powervr.com"><img border="0" src="PVRlogo.jpg" width="200" height="27"></a></p>
    </td>
  </tr>
</table>
<hr>
</head><body>
<!-- Generated by Doxygen 1.3.6 -->
<div class="qindex"><a class="qindex" href="index.html">Main&nbsp;Page</a> | <a class="qindex" href="namespaces.html">Namespace List</a> | <a class="qindex" href="hierarchy.html">Class&nbsp;Hierarchy</a> | <a class="qindex" href="annotated.html">Class&nbsp;List</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="namespacemembers.html">Namespace&nbsp;Members</a> | <a class="qindex" href="functions.html">Class&nbsp;Members</a> | <a class="qindex" href="globals.html">File&nbsp;Members</a></div>
<h1>Mesh.h</h1><a href="Mesh_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 <span class="comment">/******************************************************************************</span>
00002 <span class="comment"></span>
00003 <span class="comment"> @File         Mesh.h</span>
00004 <span class="comment"></span>
00005 <span class="comment"> @Title        Mesh.</span>
00006 <span class="comment"></span>
00007 <span class="comment"> @Version      </span>
00008 <span class="comment"></span>
00009 <span class="comment"> @Copyright    Copyright (C)  Imagination Technologies Limited.</span>
00010 <span class="comment"></span>
00011 <span class="comment"> @Platform     Independent - OGL/OGLES/OGLES2 Specific at the moment</span>
00012 <span class="comment"></span>
00013 <span class="comment"> @Description  A class for holding information about renderable meshes.</span>
00014 <span class="comment"></span>
00015 <span class="comment">******************************************************************************/</span>
00016 
00017 <span class="preprocessor">#ifndef _MESH_H_</span>
00018 <span class="preprocessor"></span><span class="preprocessor">#define _MESH_H_</span>
00019 <span class="preprocessor"></span>
00020 <span class="preprocessor">#include "PVRTools.h"</span>
00021 <span class="preprocessor">#include "<a class="code" href="Globals_8h.html">Globals.h</a>"</span>
00022 <span class="preprocessor">#include "<a class="code" href="BoundingHex_8h.html">BoundingHex.h</a>"</span>
00023 
00024 <span class="keyword">namespace </span>pvrengine
00025 {
00026     <span class="keyword">class </span>Material;
00027     <span class="keyword">class </span>MaterialManager;
00028 
00029         <span class="keyword">enum</span> <a class="code" href="namespacepvrengine.html#a97">EDrawMode</a>
00030         {
00031             <a class="code" href="namespacepvrengine.html#a97a8">eNormal</a> = 0,
00032             <a class="code" href="namespacepvrengine.html#a97a9">eNoFX</a>,
<a name="l00033"></a><a class="code" href="namespacepvrengine.html#a97">00033</a>             <a class="code" href="namespacepvrengine.html#a97a10">eWireframe</a>,
00034             <a class="code" href="namespacepvrengine.html#a97a11">eWireframeNoFX</a>,
00035             <a class="code" href="namespacepvrengine.html#a97a12">eBounds</a>,
00036             <a class="code" href="namespacepvrengine.html#a97a13">eNumDrawModes</a>
00037         }; 
00039     <span class="keyword">const</span> CPVRTString g_strDrawModeNames[eNumDrawModes]= {
00040         <span class="stringliteral">"Normal"</span>,
00041             <span class="stringliteral">"No FX"</span>,
00042             <span class="stringliteral">"Wireframe"</span>,
<a name="l00043"></a><a class="code" href="namespacepvrengine.html#a7">00043</a>             <span class="stringliteral">"Wireframe with No FX"</span>,
00044             <span class="stringliteral">"Boundaries"</span>
00045     };
00046 
00047     <span class="comment">/*!***************************************************************************</span>
00048 <span class="comment">    * @Class Mesh</span>
00049 <span class="comment">    * @Brief A class for holding information about renderable meshes.</span>
00050 <span class="comment">    * @Description A class for holding information about renderable meshes.</span>
00051 <span class="comment">    *****************************************************************************/</span>
00052     <span class="keyword">class </span>Mesh
00053     {
00054     <span class="keyword">public</span>:
00055 
00056         <span class="comment">/*!***************************************************************************</span>
<a name="l00057"></a><a class="code" href="classpvrengine_1_1Mesh.html">00057</a> <span class="comment">        @Function           Mesh</span>
00058 <span class="comment">        @Description        constructor</span>
00059 <span class="comment">        *****************************************************************************/</span>
00060         <a class="code" href="classpvrengine_1_1Mesh.html#a0">Mesh</a>();
00061 
00062         <span class="comment">/*!***************************************************************************</span>
00063 <span class="comment">        @Function           Mesh</span>
00064 <span class="comment">        @Input              psScene - POD scene where this mesh came from</span>
00065 <span class="comment">        @Input              iIndex - index into mesh list in the POD scene</span>
00066 <span class="comment">        @Input              pMaterialManager - manager for this material</span>
00067 <span class="comment">        @Description        constructor from POD structs</span>
00068 <span class="comment">        *****************************************************************************/</span>
00069         <a class="code" href="classpvrengine_1_1Mesh.html#a0">Mesh</a>(CPVRTModelPOD *psScene, <span class="keyword">const</span> <span class="keywordtype">int</span> iIndex, <a class="code" href="classpvrengine_1_1MaterialManager.html">MaterialManager</a> *pMaterialManager);
00070 
00071         <span class="comment">/*!***************************************************************************</span>
00072 <span class="comment">        @Function           ~Mesh</span>
00073 <span class="comment">        @Description        destructor</span>
00074 <span class="comment">        *****************************************************************************/</span>
00075         <a class="code" href="classpvrengine_1_1Mesh.html#a2">~Mesh</a>();
00076 
00077         <span class="comment">/*!***************************************************************************</span>
00078 <span class="comment">        @Function           ~draw</span>
00079 <span class="comment">        @Description        draws the mesh according to whatever drawmode is current</span>
00080 <span class="comment">        *****************************************************************************/</span>
00081         <span class="keywordtype">void</span> <a class="code" href="classpvrengine_1_1Mesh.html#a3">draw</a>();
00082 
00083         <span class="comment">/*!***************************************************************************</span>
00084 <span class="comment">        @Function           getNode</span>
00085 <span class="comment">        @Return             POD node associated with this mesh</span>
00086 <span class="comment">        @Description        Retrieves the POD node associated with this mesh object</span>
00087 <span class="comment">        *****************************************************************************/</span>
00088         SPODNode* <a class="code" href="classpvrengine_1_1Mesh.html#a4">getNode</a>(){<span class="keywordflow">return</span> m_psNode;}
00089 
00090         <span class="comment">/*!***************************************************************************</span>
00091 <span class="comment">        @Function           setWorldMatrix</span>
00092 <span class="comment">        @Input              mWorld The world matrix to set to</span>
00093 <span class="comment">        @Description        Sets the world matrix for this mesh object</span>
00094 <span class="comment">        *****************************************************************************/</span>
00095         <span class="keywordtype">void</span> <a class="code" href="classpvrengine_1_1Mesh.html#a5">setWorldMatrix</a>(<span class="keyword">const</span> PVRTMat4&amp; mWorld)
00096         {
00097             m_mWorld = mWorld;
<a name="l00098"></a><a class="code" href="classpvrengine_1_1Mesh.html#a4">00098</a>         }
00099 
00100         <span class="comment">/*!***************************************************************************</span>
00101 <span class="comment">        @Function           overlaps</span>
00102 <span class="comment">        @Input              sBoundingHex The bounding volume to test against</span>
00103 <span class="comment">        @Return             true if this mesh overlaps the passed volume</span>
00104 <span class="comment">        @Description        Determines whether there is an intersection between this</span>
00105 <span class="comment">        mesh and the passed bounding volume. The test used is rather crude at the moment.</span>
<a name="l00106"></a><a class="code" href="classpvrengine_1_1Mesh.html#a5">00106</a> <span class="comment">        *****************************************************************************/</span>
00107         <span class="keywordtype">bool</span> <a class="code" href="classpvrengine_1_1Mesh.html#a6">overlaps</a>(<span class="keyword">const</span> <a class="code" href="structpvrengine_1_1BoundingHex.html">BoundingHex</a>&amp; sBoundingHex);
00108 
00109         <span class="comment">/*!***************************************************************************</span>
00110 <span class="comment">        @Function           setDrawMode</span>
00111 <span class="comment">        @Input              eDrawMode the desired rendering method</span>
00112 <span class="comment">        @Return             whether the chosen mode has been successfully set</span>
00113 <span class="comment">        @Description        Sets how a mesh is rendered</span>
00114 <span class="comment">        *****************************************************************************/</span>
00115         <span class="keywordtype">bool</span> <a class="code" href="classpvrengine_1_1Mesh.html#a7">setDrawMode</a>(<span class="keyword">const</span> EDrawMode eDrawMode);
00116 
00117         <span class="comment">/*!***************************************************************************</span>
00118 <span class="comment">        @Function           getDrawMode</span>
00119 <span class="comment">        @Description        Gets the draw mode for this mesh</span>
00120 <span class="comment">        *****************************************************************************/</span>
00121         <a class="code" href="namespacepvrengine.html#a97">EDrawMode</a> <a class="code" href="classpvrengine_1_1Mesh.html#a8">getDrawMode</a>()<span class="keyword"> const   </span>{<span class="keywordflow">return</span> m_eDrawMode;}
00122 
00123         <span class="comment">/*!***************************************************************************</span>
00124 <span class="comment">        @Function           getCentre</span>
00125 <span class="comment">        @Description        gets the 'centre' point for this mesh</span>
00126 <span class="comment">        *****************************************************************************/</span>
00127         PVRTVec3 <a class="code" href="classpvrengine_1_1Mesh.html#a9">getCentre</a>() { <span class="keywordflow">return</span> m_vCentreModel;}
00128 
00129         <span class="comment">/*!***************************************************************************</span>
00130 <span class="comment">        @Function           getRadius</span>
00131 <span class="comment">        @Description        Gets the radius for this mesh</span>
00132 <span class="comment">        *****************************************************************************/</span>
00133         VERTTYPE <a class="code" href="classpvrengine_1_1Mesh.html#a10">getRadius</a>() { <span class="keywordflow">return</span> m_fRadius;}
00134 
<a name="l00135"></a><a class="code" href="classpvrengine_1_1Mesh.html#a8">00135</a> 
00136         <span class="comment">/*!***************************************************************************</span>
00137 <span class="comment">        @Function           getMaterial</span>
00138 <span class="comment">        @Description        Gets the Material for this mesh</span>
00139 <span class="comment">        *****************************************************************************/</span>
00140         <a class="code" href="classpvrengine_1_1Material.html">Material</a>* <a class="code" href="classpvrengine_1_1Mesh.html#a11">getMaterial</a>() { <span class="keywordflow">return</span> m_pMaterial;}
00141 
<a name="l00142"></a><a class="code" href="classpvrengine_1_1Mesh.html#a9">00142</a> 
00143         <span class="comment">/*!***************************************************************************</span>
00144 <span class="comment">        @Function           getDrawModeName</span>
00145 <span class="comment">        @Input              eDrawMode   the desired drawmode</span>
00146 <span class="comment">        @Return             A string for the passed drawmode</span>
00147 <span class="comment">        @Description        Retrieves a human readable string for the given DrawMode</span>
00148 <span class="comment">        *****************************************************************************/</span>
<a name="l00149"></a><a class="code" href="classpvrengine_1_1Mesh.html#a10">00149</a>         CPVRTString <a class="code" href="classpvrengine_1_1Mesh.html#a12">getDrawModeName</a>(<span class="keyword">const</span> EDrawMode eDrawMode) <span class="keyword">const</span>;
00150 
00151 
00152     <span class="keyword">private</span>:
00153         GLuint              m_gluBuffer, m_gluBoundsBuffer; 
00154         CPVRTModelPOD       *m_psScene;                     
00155         SPODNode*           m_psNode;                       
00156         SPODMesh*           m_psMesh;                       
<a name="l00157"></a><a class="code" href="classpvrengine_1_1Mesh.html#a11">00157</a>         <a class="code" href="classpvrengine_1_1Material.html">Material</a>*           m_pMaterial;                    
00158         PVRTMat4            m_mWorld;                       
00159         <a class="code" href="structpvrengine_1_1BoundingBox.html">BoundingBox</a>         m_BoundingBox;                  
00160         VERTTYPE            m_pfBoundingBuffer[40];         
00161         <a class="code" href="structpvrengine_1_1BoundingHex.html">BoundingHex</a>         m_BoundingHex;                  
00162         VERTTYPE            m_fRadius;                      
00163         PVRTVec3            m_vCentreModel;                 
00164         <a class="code" href="namespacepvrengine.html#a97">EDrawMode</a>           m_eDrawMode;                    
00166         <span class="keywordtype">bool</span>                m_bSkinned;                     
00167         GLint               m_gliSkinningLocations[4];      
00168         <span class="keyword">enum</span> ESkinningLocations
00169         {
00170             eBoneCount = 0,
00171             eBoneMatrices,
00172             eBoneMatricesI,
00173             eBoneMatricesIT
00174         }; 
00176         <span class="comment">/*!***************************************************************************</span>
00177 <span class="comment">        @Function           Init</span>
00178 <span class="comment">        @Description        Shared initialisation for Mesh constructors</span>
00179 <span class="comment">        *****************************************************************************/</span>
00180         <span class="keywordtype">void</span>    Init();
00181 
00182         <span class="comment">/*!***************************************************************************</span>
00183 <span class="comment">        @Function           CreateBuffer</span>
00184 <span class="comment">        @Description        Creates OpenGL buffers</span>
00185 <span class="comment">        *****************************************************************************/</span>
00186         <span class="keywordtype">void</span>    CreateBuffer();
00187 
00188         <span class="comment">/*!***************************************************************************</span>
00189 <span class="comment">        @Function           ConvertToLines</span>
00190 <span class="comment">        @Description        Converts the geometry in this mesh to lines (from triangles)</span>
00191 <span class="comment">        so that it can be rendered in a wireframe mode efficiently.</span>
00192 <span class="comment">        *****************************************************************************/</span>
00193         <span class="keywordtype">bool</span>    ConvertToLines();
00194 
00195         <span class="comment">/*!***************************************************************************</span>
00196 <span class="comment">        @Function           ConvertToTriangles</span>
00197 <span class="comment">        @Description        Converts the geometry in this mesh to triangles (from lines)</span>
00198 <span class="comment">        so that it can be rendered in a non-wireframe mode efficiently.</span>
00199 <span class="comment">        *****************************************************************************/</span>
00200         <span class="keywordtype">bool</span>    ConvertToTriangles();
00201 
00202         <span class="comment">/*!****************************************************************************</span>
00203 <span class="comment">        @Function       DrawMesh</span>
00204 <span class="comment">        @Description    Draws the actual geometry for a mesh of triangles</span>
00205 <span class="comment">        ******************************************************************************/</span>
00206         <span class="keywordtype">void</span>    DrawMesh();
00207 
00208         <span class="comment">/*!****************************************************************************</span>
00209 <span class="comment">        @Function       DrawWireframeMesh</span>
00210 <span class="comment">        @Description    Draws the actual geometry for a mesh of lines</span>
00211 <span class="comment">        ******************************************************************************/</span>
00212         <span class="keywordtype">void</span>    DrawWireframeMesh();
00213 
00214         <span class="comment">/*!****************************************************************************</span>
00215 <span class="comment">        @Function       DrawBounds</span>
00216 <span class="comment">        @Description    Draws the actual geometry for the bounding boxes</span>
00217 <span class="comment">        ******************************************************************************/</span>
00218         <span class="keywordtype">void</span>    DrawBounds();
00219 
00220         <span class="comment">/*!****************************************************************************</span>
00221 <span class="comment">        @Function       DrawSkinned</span>
00222 <span class="comment">        @Description    Draws the actual geometry for a mesh with bones</span>
00223 <span class="comment">        ******************************************************************************/</span>
00224         <span class="keywordtype">void</span>    DrawSkinned();
00225 
00226         <span class="comment">/*!***************************************************************************</span>
00227 <span class="comment">        @Function           DoBoundaries</span>
00228 <span class="comment">        @Description        Calculates various values to determine the boundaries, centre</span>
00229 <span class="comment">        of this mesh</span>
00230 <span class="comment">        *****************************************************************************/</span>
00231         <span class="keywordtype">void</span>    DoBoundaries();
00232 
00233         <span class="comment">/*!***************************************************************************</span>
00234 <span class="comment">        @Function           prepareSkinning</span>
00235 <span class="comment">        @Description        prepares the mesh for skinning</span>
00236 <span class="comment">        *****************************************************************************/</span>
00237         <span class="keywordtype">void</span>    prepareSkinning();
00238 
00239         <span class="comment">/*!***************************************************************************</span>
00240 <span class="comment">        @Function           &gt;</span>
00241 <span class="comment">        @Description        Used for sorting meshes by comparing against Materials used</span>
00242 <span class="comment">        *****************************************************************************/</span>
00243         <span class="keyword">friend</span> <span class="keywordtype">bool</span> <a class="code" href="classpvrengine_1_1Mesh.html#n0">operator&gt;</a>(<span class="keyword">const</span> <a class="code" href="classpvrengine_1_1Mesh.html">Mesh</a>&amp; A,<span class="keyword">const</span> <a class="code" href="classpvrengine_1_1Mesh.html">Mesh</a>&amp; B);
00244     };
00245 }
00246 <span class="preprocessor">#endif // _MESH_H_</span>
00247 <span class="preprocessor"></span>
00248 <span class="comment">/******************************************************************************</span>
00249 <span class="comment">End of file (Mesh.h)</span>
00250 <span class="comment">******************************************************************************/</span>
00251 
</pre></div><br>
<br>
<P align=left><FONT size=2><STRONG><A 
   href="http://www.imgtec.com/powervr/insider/legal/index.asp">Copyright</A> � 
   1999-2008, Imagination Technologies Ltd.</STRONG></FONT></P>
<hr>
<address style="align: left;"><small><FONT color=f0f>
Generated by <a href="http://www.doxygen.org/index.html">DOXYGEN</a> 1.3.6</small></address>
</body>
</html>
